import numpy as np


arr = np.array(
    [
        [1, 2],
        [3, 4],
        [5, 6],
        [7, 8]
    ],
    dtype=np.float32
)
print(arr)
print(arr[2], arr[3])

# 下面两个交换都不成功，下标2 3会变成一样的列表，因为是引用传递

# arr[2], arr[3] = arr[3], arr[2]

# temp = arr[2]
# arr[2] = arr[3]
# arr[3] = temp

# 下面两个可以，所以说要拷贝一份再交换

# temp = arr[2].copy()
# arr[2] = arr[3]
# arr[3] = temp

# arr[2], arr[3] = arr[3], arr[2].copy()

# 后来发现正常的写法是下面这样的
arr[[2, 3], :] = arr[[3, 2], :]

print(arr[2], arr[3])
print(arr)
